<template>
<!-- 博客首页右侧显示数据列表 -->
  <div class="grid-area-item">
    <div class="grid-area-item-inner">
      <component :is="icon"></component>
      <div class="grid-area-item-inner-right">
        <h3>{{ props.topTitle }}</h3>
        <p v-if="typeof props.endVal == 'number'">
          <count-to :startVal="0" :endVal="props.endVal" autoplay="true"  :duration="1000"></count-to>
          <span>{{ props.postFix }}</span>
        </p>
        <p v-else>
          <span>{{ props.endVal }}</span>
        </p>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import {ref,defineProps} from "vue";
const props = defineProps({
  icon:{
    required:true
  },
  endVal:{
    required:false,
    type:[Number,String],
  },
  topTitle:{
    required:false,
    type:String
  },
  postFix:{
    required:false,
    type:String
  }
})
</script>

<style lang="scss" scoped>
.grid-area-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 33.33%;
  height: 50%;
  .grid-area-item-inner {
    cursor: pointer;
    display: flex;
    align-items: center;
    width: 90%;
    height: 90%;
    padding: 8px 12px;
    border-radius: 12px;
    transition: .3s all;
    &:hover {
      background-color: white;
      box-shadow: 0px 0px 2px 1px #ececec;
    }
    .grid-area-item-inner-right {
      flex: 1;
      justify-content: start;
      align-items: center;
      margin:0px 20px;
      h3 {
        font-size: 16px;
      }
      p {
        font-weight: bolder;
        margin-bottom: 0px;
        span {
          font-size: 14px;
          color: #000;
        }
      }
    }
  }
}
</style>
